package com.sm.auth.controller;

import com.sm.auth.dto.LoginDto;
import com.sm.auth.service.IAuthService;
import com.sm.common.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("auth")
@Slf4j
public class AuthController {
    @Autowired
    private IAuthService authService;
    @Autowired
    private PasswordEncoder passwordEncoder;

    @PostMapping("sys")
    //登录接口
    public Result login(@RequestBody LoginDto loginDto) {
        log.info("用户登录：{}",loginDto);
        authService.login(loginDto);
        return Result.success();
    }
    @RequestMapping("test")
    Result test(){
        String encode = passwordEncoder.encode("123456");
        System.out.println(encode);
        return Result.success();
    }
}
